﻿using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class exame2_gun_hp : MonoBehaviour
{
    public int hp = 100;
    public GameObject deadReplaceObj;
    public GameObject expFx;
    // Start is called before the first frame update
    void Start()
    {
        
    }

    // Update is called once per frame
    void Update()
    {
        if(hp<=0)
        {
            if (deadReplaceObj != null)
                Instantiate(deadReplaceObj, transform.position, transform.rotation);
            if (expFx != null)
                Destroy(Instantiate(expFx, transform.position, transform.rotation), 3f);
            Destroy(gameObject);
        }
    }
    void TakeDamage(int damage)
    {
        //print("take damage " + damage);
        if (hp < damage)
        {
            hp = 0;
        }
        hp -= damage;
    }
}
